package kr.ac.postech.marathon.client;

import kr.ac.postech.marathon.client.pages.RegistrationPage;

import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Label;

/** 
 * The content page contains the page of contents and 
 * the message field which appears when need it.
 */
public class ContentPage extends Composite implements ValueChangeHandler<String> {
	
	private VerticalPanel vPanel = new VerticalPanel();
	private Label message = new Label("no message");
	
	private RegistrationPage resForm = new RegistrationPage();
	
	public ContentPage() {
		vPanel.add(message);
		vPanel.add(resForm);
		
		// Listening changes of history
		History.addValueChangeHandler(this);
		
		initWidget(vPanel);
	}
	
	public void setMessage(String msg) {
		message.setText(msg);
	}

	public void onValueChange(ValueChangeEvent<String> event) {
		// TODO Auto-generated method stub
		message.setText(event.getValue());
		
		if(event.getValue().equals("register")) {
			resForm.setVisible(true);
		}
		else{
			resForm.setVisible(false);
		}
	}
}
